package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class BeerServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest request, 
						HttpServletResponse response) throws IOException, ServletException{
		
		
		String c = request.getParameter("color");
		BeerExpert be = new BeerExpert();
		List<String> result = be.getBrands(c);
		
//		response.setContentType("text/html");
//		PrintWriter out = response.getWriter();
//		out.println("Beer Selection Advice<br>");
//		out.println("<br>Got beer color " + c);
		
//		Iterator it = result.iterator();
//		while(it.hasNext()){
//			out.print("<br>try: "+it.next());
//		}
		
		request.setAttribute("styles", result);
		
		RequestDispatcher view =  request.getRequestDispatcher("result.jsp");
		view.forward(request, response);
		
	}
	
}
